﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Runda.CMS.Common.Utility;
using Runda.CMS.Common.Entity;
using Runda.CMS.Bll;

namespace Runda.CMS.Portal.SyncManage
{
    public partial class BillDetailList : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack) {
                BindBillDetailList(1);
            }
        }

        private void BindBillDetailList(int pageindex)
        {
            if (Request.QueryString["billGUID"] != null && Request.QueryString["billGUID"].ToString() != "")
            {
                List<SqlDbParameter> parms = new List<SqlDbParameter>();
                SqlDbParameter parm = new SqlDbParameter();
                parm.ColumnName = "billGUID";
                parm.ColumnType = System.Data.DbType.String;
                parm.ParameterName = "@billGUID";
                parm.ParameterValue = Request.QueryString["billGUID"].ToString();
                parm.QualificationType = SqlDbParameter.QualificationSymbol.Equal;
                parms.Add(parm);

                int RecordCount = 0;
                List<CtrtBilldetailEntity> list = new CtrtBilldetailBll().GetAll<CtrtBilldetailEntity>(parms, "CreatedOn desc", AspNetPager1.PageSize, pageindex, out RecordCount);

                RepeaterBillDetails.DataSource = list;
                RepeaterBillDetails.DataBind();
                AspNetPager1.RecordCount = RecordCount;
            }
        }
        protected void RepeaterBillDetails_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "refersh")
            {
                BindBillDetailList(1);
            }
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            BindBillDetailList(AspNetPager1.CurrentPageIndex);
        } 
    }
}
